Skip to content

master gremlin: Initialize preview interpreter with active modal gcodes#4123

Open
Sigma1912 wants to merge 1 commit into
LinuxCNC:masterfrom
Sigma1912:gremlin_fix_initializing_preview_interp
Open

master gremlin: Initialize preview interpreter with active modal gcodes#4123
Sigma1912 wants to merge 1 commit into
LinuxCNC:masterfrom
Sigma1912:gremlin_fix_initializing_preview_interp

Conversation

@Sigma1912
Copy link
Copy Markdown
Contributor

fixes #4121 and improves preview for gcode with incomplete preambles.

No regression on #2753
No regression on #3855

Affects gmoccapy and any other gui using gremlin.

@Sigma1912 Sigma1912 changed the title gremlin: Initialize preview interpreter with active modal gcodes master gremlin: Initialize preview interpreter with active modal gcodes Jun 4, 2026
@Sigma1912 Sigma1912 force-pushed the gremlin_fix_initializing_preview_interp branch from 7dda1b6 to 93bf5ad Compare June 4, 2026 08:13
Comment thread src/emc/usr_intf/gremlin/gremlin.py Outdated
Improve preview for gcode with incomplete preambles
@Sigma1912 Sigma1912 force-pushed the gremlin_fix_initializing_preview_interp branch from 93bf5ad to bd031ae Compare June 4, 2026 13:12
@grandixximo
Copy link
Copy Markdown
Contributor

s.gcodes is scaled by 10 (G21=210, G38.2=382). In Py3 active_gcodes[i]/10 is float division: 170 -> 'G17.0' (invalid), 382 -> 'G38.2' (ok). Whole codes get a stray .0 and won't parse.

hal_glib.py does it right:

code = "G%d" % (i//10) if i%10==0 else "G%d.%d" % (i//10, i%10)

Suggest same split, and a test that initcode round-trips through the interpreter.

@c-morley
Copy link
Copy Markdown
Collaborator

c-morley commented Jun 4, 2026

As qr_graphics uses very similar cide, can you add to or create a pull request for it too? I'm away working and dont want to get them out of step.

@Sigma1912
Copy link
Copy Markdown
Contributor Author

@grandixximo

Whole codes get a stray .0 and won't parse.

It's an easy enough change but having a trailing .0 parses fine for me.
Examples:

  • G7.0 does the same as G7
  • G0.0 X1 does the same as G0 X1

I'll have a look at adding a test. Do you have any pointers on how I might test the preview?

@c-morley
Sure, I'll have a look as soon as this is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(gremlin): incorrect gcode checking due to wrong initialization

3 participants